package com.cskaoyan.controller;

import com.cskaoyan.bean.bo.AdminKeywordCreateBo;
import com.cskaoyan.bean.bo.AdminKeywordDeleteBo;
import com.cskaoyan.bean.bo.AdminKeywordListBo;
import com.cskaoyan.bean.bo.AdminKeywordUpdateBo;
import com.cskaoyan.bean.vo.AdminOrderShipVo;
import com.cskaoyan.bean.vo.admin_keyword_create.AdminKeywordCreateVo;
import com.cskaoyan.bean.vo.admin_keyword_list.AdminKeywordListVo;
import com.cskaoyan.bean.vo.admin_keyword_update.AdminKeywordUpdateVo;
import com.cskaoyan.service.AdminKeywordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;

/**
 * @author Trellis
 * @since 2022/09/07 20:19
 */
@RestController
@RequestMapping("admin/keyword")
public class AdminKeywordController {

    @Autowired
    AdminKeywordService adminKeywordService;


    /**
     * 1、获取请求参数 limit page等
     * 2、根据请求参数 在数据库中进行查询
     * 3、返回响应信息 返回查询的数据
     *
     * @param keywordListBo
     * @return com.cskaoyan.bean.vo.admin_keyword_list.AdminKeywordListVo
     * @author Trellis
     * @since 2022/09/07 20:35
     */
    @RequestMapping("list")
    public AdminKeywordListVo keyWordList(AdminKeywordListBo keywordListBo) {
        AdminKeywordListVo adminKeywordListVo = adminKeywordService.selectByListBo(keywordListBo);
        return adminKeywordListVo;
    }


    /**
     * @param createBo
     * @return com.cskaoyan.bean.vo.admin_keyword_create.AdminKeywordCreateVo
     * @author Trellis
     * @since 2022/09/08 10:49
     */
    @RequestMapping("create")
    public AdminKeywordCreateVo keywordCreate(@RequestBody AdminKeywordCreateBo createBo) throws ParseException {
        AdminKeywordCreateVo keywordCreateVo = adminKeywordService.insertByCreateBo(createBo);
        return keywordCreateVo;
    }


    /**
     * @param updateBo
     * @return com.cskaoyan.bean.vo.admin_keyword_update.AdminKeywordUpdateVo
     * @author Trellis
     * @since 2022/09/08 11:13
     */
    @RequestMapping("update")
    public AdminKeywordUpdateVo keywordUpdate(@RequestBody AdminKeywordUpdateBo updateBo) {
        AdminKeywordUpdateVo updateByBo = adminKeywordService.updateByBo(updateBo);
        return updateByBo;
    }

    /**
     * 返回响应信息 复用AdminOrderShipVo
     *
     * @param
     * @return
     * @author Trellis
     * @since 2022/09/08 11:51
     */
    @RequestMapping("delete")
    public AdminOrderShipVo keywordDelete(@RequestBody AdminKeywordDeleteBo deleteBo) {
        AdminOrderShipVo orderShipVo = adminKeywordService.deleteByBo(deleteBo);
        return orderShipVo;
    }
}
